#!/usr/bin/python3
# -*- coding.utf-8 -*-

from student import stu_api

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn


from employment import emp_api
from score import score_api
from statistics import sta_api

# 主入口

app = FastAPI(
    title="沃林学生信息管理系统",
    description="对所有的学员，学习过程，班级，成绩进行管理",
    version="v0.0.1"
)

# 配置CORS中间件
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],  # 允许所有来源
    allow_credentials=True,
    allow_methods=["*"],  # 允许所有HTTP方法
    allow_headers=["*"],  # 允许所有HTTP头
)

# Base.metadata.create_all(bind=engine)

# 加载子路由
app.include_router(emp_api, prefix="/employment", tags=["就业信息管理"])
app.include_router(score_api, prefix="/score", tags=["成绩管理"])
app.include_router(stu_api, prefix="/students", tags=["学生信息管理"])
app.include_router(sta_api, prefix="/statistics", tags=["统计分析"])

if __name__ == '__main__':
    uvicorn.run("main:app", host="localhost", port=8000, reload=True)
